package com.xintouyun.medicine.service.impl;

import java.util.List;

import javax.servlet.annotation.WebServlet;

import com.xintoucloud.jdbcutil.JdbcUtil;
import com.xintouyun.medicine.dao.ProviderDao;
import com.xintouyun.medicine.entity.Provider;
import com.xintouyun.medicine.model.DataGrid;
import com.xintouyun.medicine.service.ProviderService;
@WebServlet("/provider/login")
public class ProviderServiceImpl implements ProviderService{
	private ProviderDao providerdao=new ProviderDao();
	@Override
	public DataGrid<Provider> List(int page, int rows) {
		try {
			DataGrid <Provider> data=new DataGrid<>();
			int count=providerdao.count("select count(*) from m_provider",null);
			List<Provider> providers=providerdao.list("select name,sname from m_provider limit ?,?",(page-1)*rows,rows);
			data.setTotal(count);
			data.setRows(providers);
			return data;
		}finally {
			JdbcUtil.closeConnection();
		}
	}
	@Override
	public Provider Login(String name, String upwd) {
		try {
			return providerdao.get("select * from m_provider where name=? and upwd=?",name,upwd);
		}finally {
			JdbcUtil.closeConnection();
		}
		
	}

}
